import { toSuccess, useEntityManager } from "@sker/core"
import { KsOpen } from "@sker/entities"
import { useData } from "@sker/runtime"
import { z } from "zod"

export default async () => {
    const input = z.object({
        open: z.string(),
        p: z.string()
    })
    const body = input.parse(useData())
    return await useEntityManager(async m => {
        const e = m.create(KsOpen, {
            open: body.open,
            platform: body.p,
            status: '0'
        })
        await m.save(KsOpen, e)
        return toSuccess(body)
    })
}